package com.yunfeisoft.business.dao.impl.postgres;

import com.applet.base.ServiceDaoImpl;
import com.applet.sql.builder.WhereBuilder;
import com.applet.utils.Page;
import com.yunfeisoft.business.dao.inter.SmsHomeAdvertiseDao;
import com.yunfeisoft.business.model.SmsHomeAdvertise;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * ClassName: SmsHomeAdvertiseDaoImpl
 * Description: 首页轮播广告表Dao实现
 * Author: Jackie liu
 * Date: 2020-06-02
 */
@Repository
public class SmsHomeAdvertiseDaoImpl extends ServiceDaoImpl<SmsHomeAdvertise, String> implements SmsHomeAdvertiseDao {

    @Override
    public Page<SmsHomeAdvertise> queryPage(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        if (params != null) {
            initPageParam(wb, params);
            wb.andFullLike("name", params.get("name"));
        }
        return queryPage(wb);
    }

    /**
     * 查询广告列表
     * @param params
     * @return
     */
    @Override
    public List<SmsHomeAdvertise> queryAdvertList(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        wb.setOrderByWithDesc("createTime");
        wb.andEquals("status", 1);
        return query(wb);
    }
}